<?php
namespace app\setup\controller;
use think\Controller;
use think\Db;
use think\Session;
use think\Request;

class Contact extends Controller
{
    public function index()
    {
        //查询
        $id = Session::get('id');
        $list = Db::table('user_data')->where('uid',$id)->find();
        $list_info = Db::table('user_info')->where('uid',$id)->find();
        $a = Session::get('name');
        // var_dump($list_info['pname']);
        var_dump($list_info['pname']);
       

        var_dump($id);
        var_dump($list);
        $this->assign('list',$list);
        $this->assign('list_info',$list_info);
        // $this->assign('phone',$list['phone']);
        // $this->assign('address_live',$list['address_live']);
        // $this->assign('job',$list['job']);
        // $this->assign('qq',$list['qq']);
        // $this->assign('email',$list['email']);
        
        return $this->fetch('index/contact');
    }

    //更新数据
    public function update()
    {
        if(request()->isPost()){
            //获取提交的数据
        $data = Request::instance()->post();
        
        $id = Session::get('id');
        var_dump($data);
        }
        
        $result = Db::table('user_data')->where('uid',$id)->update(['phone'=>$data['phone'],'address_live'=>$data['address_live'],'job'=>$data['job'],'qq'=>$data['qq'],'email'=>$data['email']]);
        var_dump($result);
        return $this->redirect('contact/index');
    }
}
